package com.theten52.demo.io.s1;

import java.io.IOException;
import java.net.Socket;

/**
 * 客户端和服务端互联
 *
 * @author wangjin
 * @date 2021/3/11
 */
public class ClientMain {

    public static void main(String[] args) {
        //开启服务
        System.out.println("开启服务,监听端口:" + Constant.PORT);
        new Thread(new ServerThread()).start();

        //建立一个socket客户端,发起请求
        System.out.println("客户端,请求连接,并发送数据");
        try {
            Socket socket = new Socket(Constant.HOST, Constant.PORT);
            new Thread(new ClientProcessThread(socket)).start();
            //开启新的线程处理socket连接
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
